<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 스타 랭킹 관리 컨트롤러
 */
class Ranking extends CI_Controller {
	
	var $data = array();
	
	function __construct() {
		parent::__construct();

		$this->load->model('star/Ranking_model', 'star');
	}
	
	// Default
	function index() {
		$this->ranking_list();
	}
	
	/*******************************************************************
	 * 스타 궁합 랭킹 리스트
	 *******************************************************************/
 	function ranking_list() {
		log_message('debug', "@@@@ Ranking::ranking_list()");
		
		$target_date = $this->input->get('yyyymm', TRUE);
		$target_date = !empty($target_date) ? $target_date.'01' : date('Ymd',time());
		
		$this->data['list'] = $this->star->select_star_ranking_list('star_gunghap',$target_date);
		
		$this->load->view('star/ranking_list_v', $this->data);
	}

	/*******************************************************************
	 * 스타 궁합 랭킹 조회수 수정
	 *******************************************************************/
	function modify_hit() {
		log_message('debug', "@@@@ Ranking::modify_hit()");

		$yyyy       = $this->input->post('yyyy', TRUE);
		$mm         = $this->input->post('mm', TRUE);
		$dd         = $this->input->post('dd', TRUE);
		$artist_idx = $this->input->post('artist_idx', TRUE);
		$op         = $this->input->post('op', TRUE);
		
		$cnt = rand(5,10);
		if ($op == 'sub') {
			$cnt = -$cnt;
		}
		
		$this->star->insert_update_star_statistics('star_gunghap',$yyyy, $mm, $dd, $artist_idx, $cnt);
		
		redirect("/star/ranking");
	}

	/*******************************************************************
	 * 스타 궁합 랭킹 추가 처리
	 *******************************************************************/
	function write_ok() {
		log_message('debug', "@@@@ Ranking::write_ok()");

		$yyyy        = $this->input->post('yyyy', TRUE);
		$mm          = $this->input->post('mm', TRUE);
		$dd          = $this->input->post('dd', TRUE);
		$artist_idx  = $this->input->post('artist_idx', TRUE);
		
		$this->star->insert_update_star_statistics('star_gunghap',$yyyy, $mm, $dd, $artist_idx, 1);
		
		redirect("/star/ranking");
	}

}


/* End of file ranking.php */
/* Location: ./application/controllers/star/ranking.php */